package icu.luoxi.utils;

import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;

/**
 * @author Cao Jiwen
 * @date 2025/5/17 16:39
 * @description 类工具
 */
public class ClassUtils {

    public static String getDbColumn(Class<?> clazz, String fieldName) {
        try {
            Field field = clazz.getDeclaredField(fieldName);
            TableField tableField = field.getAnnotation(TableField.class);
            return tableField != null ? tableField.value() : fieldName;
        } catch (NoSuchFieldException e) {
            return fieldName;
        }
    }
}
